{
  LW Host -- LightWave Host Services

  This unit contains the declarations for globals provided by all
  LightWave host applications.

  Based on lwhost.h which is:
  Copyright 1999, NewTek, Inc.
}

{
  Copyright 2012, Jameel Halabi

  This unit is part of the BlaiseWave wrapper,
  which is licensed under the BSD 2-Clause license (see licenses/license.txt).
}


unit LW_Host;

{$mode objfpc}{$H+}

interface

uses
  LW_Dialog;

const
  LWFILEREQFUNC_GLOBAL       = 'File Request'     ;
  LWFILEACTIVATEFUNC_GLOBAL  = 'File Request 2'   ;
  LWCOLORACTIVATEFUNC_GLOBAL = 'Color Picker'     ;
  LWFILETYPEFUNC_GLOBAL      = 'File Type Pattern';
  LWDIRINFOFUNC_GLOBAL       = 'Directory Info'   ;
  LWMESSAGEFUNCS_GLOBAL      = 'Info Messages 3'  ;
  LWSYSTEMID_GLOBAL          = 'System ID'        ;
  LWPRODUCTINFO_GLOBAL       = 'Product Info'     ;
  LWLOCALEINFO_GLOBAL        = 'Locale Info'      ;

  LWCOMMANDFUNC_GLOBAL       = 'LW Command Interface';

  {
    These file type code strings are recognized by the File Type and Directory Info
    Functions. They correspond with the current configuration for the system.
  }
  LWFTYPE_CONTENT   = 'Content'   ;
  LWFTYPE_ANIMATION = 'Animations';
  LWFTYPE_IMAGE     = 'Images'    ;
  LWFTYPE_ENVELOPE  = 'Envelopes' ;
  LWFTYPE_MOTION    = 'Motions'   ;
  LWFTYPE_OBJECT    = 'Objects'   ;
  LWFTYPE_PLUGIN    = 'Plug-ins'  ;
  LWFTYPE_PREVIEW   = 'Previews'  ;
  LWFTYPE_PSFONT    = 'PSFonts'   ;
  LWFTYPE_SCENE     = 'Scenes'    ;
  LWFTYPE_SETTING   = 'Settings'  ;
  LWFTYPE_SURFACE   = 'Surfaces'  ;
  LWFTYPE_NODES     = 'Nodes'     ;
  LWFTYPE_SOUNDS    = 'Sounds'    ;
  LWFTYPE_DYNAMICS  = 'Dynamics'  ;
  LWFTYPE_RIGS      = 'Rigs'      ;
  LWFTYPE_INSTALL   = 'Install'   ;
  LWFTYPE_LIGHTS    = 'Lights'    ;
  LWFTYPE_RADIOSITY = 'Radiosity' ;
  LWFTYPE_VERTCACHE = 'VertCache' ;

  {
    System Information.  The value returned as the "System ID" global is
    a value that should be parsed into bits.  The low bits are the dongle
    serial number and the high bits are the application code.
  }
  LWSYS_TYPEBITS    = $F0000000;
  LWSYS_SERIALBITS  = $0FFFFFFF;

  LWSYS_LAYOUT      = $00000000;
  LWSYS_MODELER     = $10000000;
  LWSYS_SCREAMERNET = $20000000;
  LWSYS_OTHER       = $80000000;

  {
    Product Information.  The value returned as the "Product Info" global
    is a value that should be parsed into bits.  The various groups of
    bits contain codes for the specific product and revision.
  }
  LWINF_PRODUCT    = $0000000F;
  LWINF_BUILD      = $0000FFF0;
  LWINF_MINORREV   = $000F0000;
  LWINF_MAJORREV   = $00F00000;
  LWINF_RESERVED   = $FF000000;

  LWINF_PRODLWAV   = $00000001;
  LWINF_PRODINSP3D = $00000002;
  LWINF_PRODOTHER  = $00000004;

  {
    Locale Information.  The value returned as the "Locale Info" global
    is a value whose low bits contain the locale ID for the host
    application.  The possible values are the LANGID codes defined in
    lwserver.
  }
  LWLOC_LANGID   = $0000FFFF;
  LWLOC_RESERVED = $FFFF0000;

type
  {
    File Request Function.  This function is returned as the "File Request"
    global service.  It gets a simple filename from the user.
  }
  TLWFileReqFunc       = function
                         (const Hail     : PChar            ;
                                Name     : PChar            ;
                                Path     : PChar            ;
                                FullName : PChar            ;
                                BufLen   : Integer          ) : Integer;

  {
    File Request Activate Function.  This function is returned as the
    "File Request 2" global service.  It takes a file request local struct
    and version number and returns the activation code directly.
  }
  TLWFileActivateFunc  = function
                         (      Version  : Integer          ;
                                Local    : PLWFileReqLocal  ) : Integer;

  {
    Color Picker Activate Function.  This function is returned as the
    "Color Picker" global service.  It takes a color picker local struct
    and version number and returns the activation code directly.
  }
  TLWColorActivateFunc = function
                         (      Version  : Integer          ;
                                Local    : PLWColorPickLocal) : Integer;

  {
    File Type Function.  This function is returned as the "File Type Pattern"
    global service.  It returns filename pattern strings given file type
    code strings.
  }
  TLWFileTypeFunc      = function
                         (const Type_    : PChar            ) : PChar  ;

  {
    Directory Function.  This function is returned as the "Directory Info"
    global service.  It returns filename pattern strings given file type
    code strings.
  }
  TLWDirInfoFunc       = function
                         (const DirType  : PChar            ) : PChar  ;

  {
    Layout makes available a global that allows plug-ins of any class,
    not just generics and masters, to issue commands.
  }
  TLWCommandFunc       = function
                         (const Cmd      : PChar            ) : Integer;

  {
    Message Functions.  This block of functions is returned as the
    "Info Messages 3" global service.  They display various info
    and other confirmation dialogs to the user.
    The return codes are as follows:
     OKCancel                     ok(1) cancel(0)
     YesNo                       yes(1) no(0)
     YesNoCancel           yes(2) no(1) cancel(0)
     YesNoAll    yesAll(3) yes(2) no(1) cancel(0)
  }
  PLWMessageFuncs = ^TLWMessageFuncs;
  TLWMessageFuncs = record
    Info:     procedure
              (const Line1    : PChar;
               const Line2    : PChar) ;
    Error:    procedure
              (const Line1    : PChar;
               const Line2    : PChar) ;
    Warning:  procedure
              (const Line1    : PChar;
               const Line2    : PChar) ;
    OkCancel: function
              (const Title    : PChar;
               const Line1    : PChar;
               const Line2    : PChar) : Integer;
    YesNo:    function
              (const Title    : PChar;
               const Line1    : PChar;
               const Line2    : PChar) : Integer;
    YesNoCan: function
              (const Title    : PChar;
               const Line1    : PChar;
               const Line2    : PChar) : Integer;
    YesNoAll: function
              (const Title    : PChar;
               const Line1    : PChar;
               const Line2    : PChar) : Integer;
    AskName:  function
              (const Title    : PChar;
               const ALabel   : PChar;
               const InitName : PChar) : PChar  ;
  end;

function LWINF_GETMAJOR(X : UInt32) : UInt32;
function LWINF_GETMINOR(X : UInt32) : UInt32;
function LWINF_GETBUILD(X : UInt32) : UInt32;

implementation

function LWINF_GETMAJOR(X : UInt32) : UInt32; inline;
begin
  Result := (X and LWINF_MAJORREV) shr 20;
end;
function LWINF_GETMINOR(X : UInt32) : UInt32; inline;
begin
  Result := (X and LWINF_MINORREV) shr 16;
end;
function LWINF_GETBUILD(X : UInt32) : UInt32; inline;
begin
  Result := (X and LWINF_BUILD) shr 4;
end;

end.

